﻿using CADTool_LinXi;
using HaierCADplug_in.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace HaierCADplug_in.View
{
    /// <summary>
    /// MessageBoardWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MessageBoardWindow : Window
    {
        public MessageBoardWindow()
        {
            InitializeComponent();
        }

        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            //获取文本框信息
            string message = messageTextBox.Text;
            await SendMessage(message);
        }

        private async Task SendMessage(string message)
        {
            //生成信息体
            MessageData messageData = new MessageData { Content = message };
            HttpHelper  httpHelper= new HttpHelper();
            //读取配置信息的API接口地址
            string apiMessageUrl = ConfigurationManager.AppSettings["ApiMessageUrl"];            
            //获取返回信息
            string Result= await httpHelper.PostAsync(apiMessageUrl, messageData);
            MessageBox.Show(Result);
        }
    }
}
